package br.ueg.ezrides.visao.composer;

import java.util.Map;

import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zul.Window;

import br.com.vexillum.util.ReflectionUtils;

@SuppressWarnings("serial")
public class ProfileComposer extends UserComposer {

	public void doAfterCompose(Component comp) throws Exception{
		super.doAfterCompose(comp);	
		if(!(haveIdOnRequest() && initUserById(Executions.getCurrent().getParameter("id")))){
			Executions.sendRedirect("/timeout.zul");
		} 
		loadBinder();
	}

	public void callModalWindow(String page){
		Map<String, Object> map = ReflectionUtils.prepareDataForPersistence(this);
		
		Component comp = Executions.createComponents(page, null, map);				
         
        if(comp instanceof Window) {
            ((Window)comp).doModal();
        }
	}
}
